<%@page pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/core/common/taglibs.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
	<jsp:include page="/WEB-INF/core/common/top.jsp"></jsp:include>
	</head>
	<base target="_self" />
	<body onload="execResult();">
		<form name="errorForm" action="${ctx}/error.action"
			target="mainframe">
			<s:if test="%{#session.GLOBAL_ERROR_INFO_KEY != null}">
				<s:iterator value="#session.GLOBAL_ERROR_INFO_KEY" id="msg">
					<input type="hidden" name="errorInfo" value="#msg" />
				</s:iterator>
			</s:if>

			<s:if test="%{#session.GLOBAL_DETAIL_ERROR_INFO_KEY != null}">
				<input type="hidden" name="error_detail"
					value="${GLOBAL_DETAIL_ERROR_INFO_KEY}" />
			</s:if>
		</form>
	</body>
	<script language="javascript">
    function showErrorMsg(msgArray){
		try{
		    if (parent && parent.mainframe){
			    if (parent.mainframe.document.errMsgBlockId){
					parent.mainframe.showMsg(msgArray);
				}else{
				    document.errorForm.submit();
				    //window.open("${base}/error.action","mainframe");
				}
			}else{
			    document.errorForm.submit();
			}
		}catch(e){
		    alert(e.description);
		    document.errorForm.submit();
		}
    }
	function execResult(){
	    var msgArrayObj = new Array();
	    var successUrl = "";
	    var systime = (new Date()).getTime();
	    
	    <s:if test="%{#session.GLOBAL_ERROR_INFO_KEY != null}">
				<s:iterator value="#session.GLOBAL_ERROR_INFO_KEY" id="msg">
					msgArrayObj.push("#msg");
				</s:iterator>
		</s:if>
		 
		<s:set name="clearMsg" value="true"/>
		<s:if test="%{#session.ACTION_EXEC_RESULT!=null}">
     			<s:if test="%{#session.ACTION_EXEC_RESULT=='iframe_error' || #session.ACTION_EXEC_RESULT=='iframe_exception' || #session.ACTION_EXEC_RESULT=='repeat_submit' }">
    				 showErrorMsg(msgArrayObj);
				</s:if>
				<s:elseif test="%{#session.ACTION_EXEC_RESULT=='iframe_success'}">
					
    				 successUrl = "${ACTION_SUCCESS_URL}"; 
			    	if (successUrl.indexOf("?")>0){
			       		successUrl = successUrl + "&systime=" + systime;
			    	}else{
			      		successUrl = successUrl + "?systime=" + systime;
			   		 }
			    	window.open(successUrl,"mainframe");
				</s:elseif>
				<s:elseif test="%{#session.ACTION_EXEC_RESULT=='timeout'}">
    				window.open("${ctx}/timeout.action?systime="+systime,"mainframe");
				</s:elseif>
		</s:if>
		<s:else>
			showErrorMsg(msgArrayObj);
		</s:else>
	}			
</script>
</html>